package com.op.teachingliteapp.database.table;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.op.teachingliteapp.BuildConfig;

/**
 * 课程讨论组表
 * 
 * @author Michael
 * @date Jun 23, 2015
 */
public class SeminarTable implements BaseColumn {

	private static final String TAG = SeminarTable.class.getSimpleName();

	// Seminar table
	public static final String TABLE_SEMINAR = "seminar";
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_CONTENT = "content";
	public static final String COLUMN_COURSE_ID = "courseId";
	public static final String COLUMN_PARENT_ID = "parentId";
	public static final String COLUMN_IS_FAVOURITE = "isFavourite";
	public static final String COLUMN_CHILD_COUNT = "childCount";
	public static final String COLUMN_IS_LIKE_COUNT = "likeCount";
	public static final String COLUMN_IMAGE_URL = "imageUrl";

	public static final String COLUMN_USER_ID = "userId";
	public static final String COLUMN_USER_NAME = "userName";
	public static final String COLUMN_USER_NUMBER = "userNumber";
	public static final String COLUMN_USER_PHONE = "userPhone";
	public static final String COLUMN_USER_EMAIL = "userEmail";
	public static final String COLUMN_USER_IS_USING = "userIsUsing";
	public static final String COLUMN_USER_TYPE = "userType";
	public static final String COLUMN_USER_IMAGE_URL = "userImageUrl";

	public static final String[] PROJECTION = { COLUMN_ID, COLUMN_TITLE, COLUMN_CONTENT, COLUMN_CREATE_TIME, COLUMN_UPDATE_TIME, COLUMN_COURSE_ID, COLUMN_PARENT_ID, COLUMN_USER_ID, COLUMN_IS_FAVOURITE, COLUMN_CHILD_COUNT, COLUMN_IS_LIKE_COUNT, COLUMN_USER_NAME, COLUMN_USER_NUMBER, COLUMN_USER_PHONE,
			COLUMN_USER_EMAIL, COLUMN_IMAGE_URL, COLUMN_USER_IMAGE_URL, COLUMN_USER_IS_USING, COLUMN_USER_TYPE };

	// Table creation SQL statement
	private static final String CREATE_TABLE = "create table " + TABLE_SEMINAR + "(" + COLUMN_ID + " text primary key, " + COLUMN_TITLE + " text, " + COLUMN_CONTENT + " text, " + COLUMN_CREATE_TIME + " text, " + COLUMN_UPDATE_TIME + " text, " + COLUMN_COURSE_ID + " text, " + COLUMN_PARENT_ID
			+ " text, " + COLUMN_USER_ID + " text, " + COLUMN_USER_NAME + " text, " + COLUMN_USER_NUMBER + " text, " + COLUMN_USER_PHONE + " text, " + COLUMN_USER_EMAIL + " text, " + COLUMN_IMAGE_URL + " text, " + COLUMN_IS_FAVOURITE + " text, " + COLUMN_CHILD_COUNT + " text, " + COLUMN_IS_LIKE_COUNT + " text, "
			+ COLUMN_USER_IS_USING + " text, " + COLUMN_USER_IMAGE_URL + " text, " + COLUMN_USER_TYPE + " text" + ");";

	public static void onCreate(SQLiteDatabase db) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Creating seminar table");
		}
		db.execSQL(CREATE_TABLE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Upgrading seminar table");
		}
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_SEMINAR);
		onCreate(db);
	}
}
